package com.ss.android.article.base.app;

import android.content.SharedPreferences;
import android.os.AsyncTask;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.c.SharedPreferenceCompat;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.newmedia.MediaAppData;
import java.io.File;
import com.ss.android.article.base.app.JsConfigHelper.a;

final class p extends AsyncTask {
    private final a b;
    private final int a;

    p(a arg1, int arg2) {
        this.b = arg1;
        this.a = arg2;

    }

    private Boolean a() {
        try {
            if(!this.b.m.exists()) {
                this.b.m.mkdirs();
            }
            else {
                ToolUtils.c(this.b.m.getAbsolutePath());
            }

            if(!this.b.mJsConfigHelper.copyJsData(this.b.jsDataPath, this.b.m.getAbsolutePath(), this.b.jsDataFileName)) {
                Boolean v0_1 = Boolean.valueOf(false);
                return v0_1;
            }

            File v0_2 = new File(this.b.m, this.b.jsDataFileName);
            if(!v0_2.isFile()) {
                return Boolean.valueOf(false);
            }

            if(!this.b.a(v0_2, this.b.m)) {
                return Boolean.valueOf(false);
            }

            if(this.b.isLocalAssetsExists(this.b.m)) {
                return Boolean.valueOf(true);
            }

            Logger.w("AppData", "validate js version failed");
        }
        catch(Throwable v0) {
        }

        return Boolean.valueOf(false);
    }

    protected final Object doInBackground(Object[] arg2) {
        return this.a();
    }

    protected final void onPostExecute(Object arg4) {
        if(((Boolean)arg4).booleanValue()) {
            this.b.assetJsVersion = this.a;
            try {
                SharedPreferences.Editor editor = MediaAppData.getSharedPreference(this.b.mJsConfigHelper.mContext).edit();
                editor.putInt(this.b.KEY_ASSET_JS_VERSION, this.b.assetJsVersion);
                SharedPreferenceCompat.commit(editor);
            }
            catch(Exception v0) {
            }
        }

        this.b.n = false;
    }
}

